package com.start.common.dataImport;

import io.swagger.v3.oas.annotations.media.Schema;

import java.util.ArrayList;
import java.util.List;

 @Schema(name="数据交换队列")
public class DataExchangeQueue {
    private static final List<DataExchangeEntity> queueList = new ArrayList<>();
    private static final DataExchangeQueue queue = new DataExchangeQueue();

    public static DataExchangeQueue getQueue() {
        return queue;
    }

    private DataExchangeQueue() {
        if (queue != null) throw new RuntimeException("队列创建失败");
    }

    public void in(DataExchangeEntity entity) {
        queueList.add(0, entity);
    }

    public DataExchangeEntity out() {
        if (queueList.size() < 1) return null;
        return queueList.remove(queueList.size() - 1);
    }

    public int size() {
        return queueList.size();
    }
}
